//
//  PayTypeMenuCell.m
//  PigMarket
//
//  Created by mac on 2019/7/16.
//  Copyright © 2019 pigmarket.oc. All rights reserved.
//

#import "PayTypeMenuCell.h"


@interface PayTypeMenuCell ()
/**
 title
 */
@property (nonatomic , strong) UILabel *title;
/**
 icon
 */
@property (nonatomic , strong) UIImageView *icon;


@end
@implementation PayTypeMenuCell

#pragma mark - init method
+ (instancetype)cellWithTableView:(UITableView *)tableView {
    static NSString *identifierID = @"identifierID";
    PayTypeMenuCell *cell = [tableView dequeueReusableCellWithIdentifier:identifierID];
    if (cell == nil) {
        cell = [[PayTypeMenuCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifierID];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
        [self initLayout];
    }
    return self;
}

- (void)initView {
    // 添加子控件
    [self.contentView addSubview:self.title];
    [self.contentView addSubview:self.icon];
    [self.contentView addSubview:self.selectImg];
}

- (void)initLayout {
    // 布局子控件
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icon.mas_right).offset(15);
        make.centerY.mas_equalTo(self.icon.mas_centerY);
        make.height.mas_equalTo(20);
    }];
    [self.selectImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.centerY.mas_equalTo(self.icon.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(18, 18));
    }];

}
#pragma mark - target aciton

#pragma mark - getter and setter
- (void)setInfoDic:(NSDictionary *)infoDic {
    self.icon.image = [UIImage imageNamed:infoDic[@"icon"]];
    self.title.text = infoDic[@"title"];

}
- (UILabel *)title {
    if (!_title) {
        _title = [[UILabel alloc] init];
        _title.textColor = [UIColor textBlackColor];
        _title.font = [UIFont systemFontOfSize:15];
    }
    return _title;
}
- (UIImageView *)icon {
    if (!_icon) {
        _icon = [[UIImageView alloc] init];
        
    }
    return _icon;
}
- (UIImageView *)selectImg {
    if (!_selectImg) {
        _selectImg = [[UIImageView alloc] init];
        _selectImg.image = [UIImage imageNamed:@"pay_default"];

    }
    return _selectImg;
}

@end
